﻿using BizModels;
using DataModel;
using IRepositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Repositories
{
    public class MainKeywordRepository : RepositoryBase, IMainKeywordRepository
    {
        public MainKeywordRepository()
        {
            Context = new HinokyEntities();
        }

        public List<MainKeywordT> GetMainKeywordList(bool isAdmin)
        {
            List<MainKeyword> dataList = (isAdmin ? Context.MainKeyword.ToList() :  Context.MainKeyword.Where(s => s.IsUse).ToList());

            var returnValue = new List<MainKeywordT>();

            foreach (var data in dataList)
            {
                var item = new MainKeywordT
                {
                    Idx = data.Idx,
                    Keyword = data.Keyword,
                    Size = data.Size,
                    Color = data.Color,
                    LinkUrl = data.LinkUrl,
                    LinkTarget = data.LinkTarget,
                    IsUse = data.IsUse,
                    CreateUserKey = data.CreateUserKey,
                    CreateDate = data.CreateDate,
                    UpdateUserKey = data.UpdateUserKey,
                    UpdateDate = data.UpdateDate
                };

                returnValue.Add(item);
            }

            return returnValue;
        }

        public int AddMainKeyword(MainKeywordT data)
        {
            throw new NotImplementedException();
        }

        public int SetMainKeyword(MainKeywordT data)
        {
            throw new NotImplementedException();
        }
    }
}
